home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!gmandel
- From: gmandel@netcom.com (Glenn Mandelkern)
- Subject: Re: mixing static and const qualifiers for class members
- Message-ID: <gmandelDo88xo.228@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <4i6mu3$pmg@halon.vggas.com> <4i6uga$67v@cloner3.netcom.com>
- Date: Wed, 13 Mar 1996 22:25:00 GMT
- Sender: gmandel@netcom20.netcom.com
-
- In article <4i6uga$67v@cloner3.netcom.com>,
- Michael Judge <mjudge@ix.netcom.com> wrote:
- >In <4i6mu3$pmg@halon.vggas.com> JYoungman@vggas.com (James Youngman)
- >writes:
- >>
- >>How do I declare and initialise a one-per-class constant? I want to
- >do
- >>something like this:
- >>
- >>class Foo
- >>{
- >> static const int nPositions = 6;
- >> int nData[nPositions];
- >>}
- >>
- >>...how is this done?
- >>James.
- >>
- >
- >class Foo
- >{
- > enum {nPositions=6};
- > int nData[nPositions];
- >};
- >
-
- FYI, the recommended solution of using the unnamed enum is found on
- page 291 of "Thinking in C++" by Bruce Eckel.
-
- Also, page 351 of the same book shows the static const int
- example exactly as the original poster had it. According to
- the footnote on that page, some compilers may not support
- this feature of having a static const within a class.
-
- --
- ---------------------------------------------------------------------------
- Glenn Mandelkern "Hee, hee, hee, hee!" -- Questor the Elf
- gmandel@netcom.com "When passion runs deep,
- San Jose, CA you're playing for keeps" -- Keith Emerson
- Games, GUI's and Entertainment What does Motif sound like in the key of C++?
-
-